{% extends "office/equipment.html" %}
{% block content %}

<nav aria-label="Page navigation">
  <ul class="pagination">
    <li>
      <a href="{% url "list_page_equipment" prev_page %}" aria-label="Previous">
        <span aria-hidden="true">&laquo;</span>
      </a>
    </li>
    {% for c in columns %}
        {% if c == active_page %}
            <li class="active"><a href="{% url "list_page_equipment" c %}">{{ c }}</a></li>
        {% else %}
            <li><a href="{% url "list_page_equipment" c %}">{{ c }}</a></li>
        {% endif %}
    {% endfor %}
    <li>
      <a href="{% url "list_page_equipment" next_page %}" aria-label="Next">
        <span aria-hidden="true">&raquo;</span>
      </a>
    </li>
  </ul>
</nav>

<table class="table table-hover table-condensed table-bordered">
    <thead>
        <tr>
            <td bgcolor="#C9C9C9">设备ID</td>
            <td bgcolor="#C9C9C9">设备编号</td>
            <td bgcolor="#C9C9C9">设备型号</td>
            <td bgcolor="#C9C9C9">当前使用者</td>
            <td bgcolor="#C9C9C9">当前状态</td>
            <td bgcolor="#C9C9C9">设备详情</td>
            <td bgcolor="#C9C9C9">操作</td>
        </tr>
    </thead>
    <tbody>
    {% for equipment in equipments %}
        <tr class="success">
            <td><a href="{% url "show_equipment" equipment.id %}">{{ equipment.id }}</a></td>
            <td><a href="{% url "show_equipment" equipment.number %}">{{ equipment.number }}</a></td>
            <td>{{ equipment.model }}</td>
            <td>{{ equipment.user }}</td>
            <td>{{ equipment.status }}</td>
            <td><a href="{% url "show_equipment" equipment.id %}">查看详情</a></td>
            <td><button type="button" class="btn btn-primary btn-xs" id="equipment_{{ equipment.id }}">删除</button></td>
        </tr>

        <script>
            $(function () {
                $("#equipment_{{ equipment.id }}").click(function () {
                    if(confirm("确定删除 设备编号: {{ equipment.number }} 设备信息? ")){
                        $.get("/office/del_equipment?equipment_id={{ equipment.id }}", function () {
                            window.location.replace("/office");
                        });
                    }
                })
            })
        </script>
    {% endfor %}
    </tbody>
</table>

<nav aria-label="Page navigation">
  <ul class="pagination">
    <li>
      <a href="{% url "list_page_equipment" prev_page %}" aria-label="Previous">
        <span aria-hidden="true">&laquo;</span>
      </a>
    </li>
    {% for c in columns %}
        {% if c == active_page %}
            <li class="active"><a href="{% url "list_page_equipment" c %}">{{ c }}</a></li>
        {% else %}
            <li><a href="{% url "list_page_equipment" c %}">{{ c }}</a></li>
        {% endif %}
    {% endfor %}
    <li>
      <a href="{% url "list_page_equipment" next_page %}" aria-label="Next">
        <span aria-hidden="true">&raquo;</span>
      </a>
    </li>
  </ul>
</nav>
{% endblock %}